var CompanySet = function (companySet) {
  //继承BaseModel
  BaseModel.call(this);
  var self = this;
  var dataFields = ['id', 'companyName', 'isUpdate', 'isApprovalReport', 'isFeedUpdateOrder', 'isAutoApproval', 'isNeedCode', 'startShare',
    'endShare', 'inWorkShopMode', 'reportDefaultValue', 'purchasePrintIsNeetApproval', 'isMatching', 'isShowYltsTotalOnPurchase', 'mixdCycle',
    'approvalIsCanUpdateReportPrice', 'isNeedSecondApproval', 'isNeedApprovalByMaterial', 'canUpdatePriceAndUnit', 'canUpdateMaterialPosition',
    'isCanPassReport', 'isLimitMaterialNeedAll', 'isUpdateFeedOrderFeedTotal', 'feedOrderMerge', 'inOutReturnUser', 'machineGetOrderType',
    'isAutoBalance', 'inWarehouseIsAutoBalance', 'dailyReckonType', 'isSelectionDept', 'afterFinishIsCanReport', 'overTimeAddTblLog'
  ];
  var fn = {
    //初始化属性
    initData: function (companySet) {
      if (companySet === undefined) {
        companySet = {};
      }
      if (companySet.notShowTardinessStartDate !== null) {
        companySet.notShowTardinessStartDate = moment(companySet.notShowTardinessStartDate).valueOf();
      }
      if (companySet.notShowTardinessEndDate !== null) {
        companySet.notShowTardinessEndDate = moment(companySet.notShowTardinessEndDate).valueOf();
      }
      var fields = ['notShowTardinessStartDate', 'notShowTardinessEndDate'];
      fields.pushArray(dataFields);
      self.setDataFromObj(companySet, fields);

      var operateBomKqSeter = companySet.operateBomKqSeter;
      if (SysUtil.isEmpty(operateBomKqSeter)) {
        operateBomKqSeter = '';
      }
      self.operateBomKqSeter = operateBomKqSeter;
    },

    getErrorMsg: function (code) {
      var errorObj = {
        isUpdate: "选择制单物料输入类型",
        isApprovalReport: "选择报工是否需要审批号",
        startShare: "请输入合法最小占比",
        mixdCycle: "请输入合法配料周期",
        endShare: "请输入合法最大占比"
      };
      return errorObj[code];
    }
  };

  this.checkValid = function () {
    var requiredFields = ['isUpdate', 'isApprovalReport', 'startShare', 'mixdCycle', 'endShare'];
    if (!CheckVaildUtil.checkNullValue(requiredFields, this, fn.getErrorMsg)) {
      return false;
    }
    return true;
  };

  this.getObject = function () {
    var postData = {};
    this.setPostData(postData, dataFields, false, true);
    if (this.notShowTardinessStartDate !== null) {
      postData.notShowTardinessStartDate = moment(this.notShowTardinessStartDate).format("YYYY-MM-DD");
    }
    if (this.notShowTardinessEndDate !== null) {
      postData.notShowTardinessEndDate = moment(this.notShowTardinessEndDate).format("YYYY-MM-DD");
    }

    postData.operateBomKqSeter = this.operateBomKqSeter;
    return postData;
  };

  fn.initData(companySet);
};
